package cachebase

import (
	"context"
	"huijing_mall/shared/kernel/hmErrors"

	"github.com/redis/go-redis/v9"

	"huijing_mall/pkg/logger"
)

func InitRedis(opt *redis.Options) *redis.Client {
	rdb := redis.NewClient(opt)
	if _, err := rdb.Ping(context.Background()).Result(); err != nil {
		panic(hmErrors.ErrSystem("redis缓存连接失败" + err.Error()))
	}
	logger.Info("cacheBase init success")
	return rdb
}
